<%@ page pageEncoding="utf-8"%>
<table id="abtt" data-options="fit:true">
<audio autoplay="autoplay" controls="controls" >
  <source src="" />
</audio>
</table>
<div id="lbmdtl" ></div> 
<div id="addlbm"></div>	
<div id="addcpt"></div>	
<script type="text/javascript">
var albumrow=null;
	$('#abtt').treegrid({    
	    url:'${pageContext.request.contextPath }/album/queryAlbum',    
	    idField:'id',    
	    treeField:'title',
	    rownumbers:true,
	    cache:false, 
	    pagination:true,
	    pagePosition:'both',
	    onClickRow:function(row,index){
	    	albumrow = row;
	    },
	    fitColumns:true,
	    columns:[[    
	        {title:'文章名',field:'title',width:1},    
	        {field:'size',title:'音频大小',width:1,align:'right'},    
	        {field:'duration',title:'音频时长',width:1},    
	        {field:'pub_date',title:'上传时间',width:1},    
	        {field:'url',title:'路径',width:1},    
	    ]],
	    toolbar: [{
		    		text:'专辑详情',
					iconCls: 'icon-detail',
					handler: function(){
						if(albumrow==null){
							alert('请选择一行')
						}else if (albumrow.count==null){
							alert('请选择专辑')
						}else{
							$("#lbmdtl").dialog({
								title: '详情',    
							    width:400,    
							    height:400,    
							    closed: false,    
							    href: '${pageContext.request.contextPath }/album/albumDetail.jsp',    
							    modal: true, 
								/* queryParams: {   请求远程数据，可以额外传参
										name: 'easyui',
										subject: 'datagrid'
									} */
								
							});
						}
				
					}
				},'-',{
					text:'添加专辑',
					iconCls: 'icon-add',
					handler: function(){
						$("#addlbm").dialog({    
						    title: '添加专辑',    
						    width: 400,    
						    height: 400,    
						    closed: false,    
						    cache: false,    
						    href: '${pageContext.request.contextPath }/album/addAlbum.jsp',    
						    modal: true   
						});    

					}
				},'-',{
					text:'添加章节',
					iconCls: 'icon-add',
					handler: function(){
						$("#addcpt").dialog({    
						    title: '添加章节',    
						    width: 400,    
						    height: 400,    
						    closed: false,    
						    cache: false,    
						    href: '${pageContext.request.contextPath }/album/addChapter.jsp',    
						    modal: true   
						});    	
					}
				},'-',{
					text:'下载音频',
					iconCls: 'icon-download',
					handler: function(){
					albumrow = $("#abtt").treegrid('getSelected');
						if(albumrow.size==null || albumrow==null){
							alert('请选择有效文件')
						}else{
							location.href="${pageContext.request.contextPath }/album/downloadChapter?title="+albumrow.title
						}
					}
				},'-',{
					text:'在线播放',
					iconCls: 'icon-upload',
					handler: function(){
						albumrow = $("#abtt").treegrid('getSelected');
						if(albumrow.size==null || albumrow==null){
							alert('请选择有效文件')
						}else{
						$("audio").prop("src","${pageContext.request.contextPath }/album/inlineChapter?title="+albumrow.title)
							//location.href="${pageContext.request.contextPath }/album/inlineChapter?title="+albumrow.title
						}
					}
			}]
		 
	});  
	
</script>